<?php
namespace App\HttpController\Admin;

use App\Repositories\Contracts\BaseOperateRepository;
use App\Repositories\Eloquent\Admin\MemberOnlineModel;
use EasySwoole\Template\Render;

class MemberOnline extends Sys implements BaseOperateRepository {

    private  $_model;

    public function index()
    {
        $this->show('admin/memberonline/index');
    }

    public function getList()
    {
        $this->_model = new MemberOnlineModel();
        $where      = [];
        if(!empty($this->_params['key'])){
            $map    = $this->_params['key'];
            $map['id'] ? $where['id'] = $map['id'] : null;
            $map['name'] ? $where['name'] = ['%' . $map['name'] . '%', 'like'] : null;
        }
        $where['a.status'] = [[0,1],'in'];
        $where['a.deleted'] = 0;
        $datas  = $this->_model->getList($where);
        $this->ajaxSuccess($datas['datas'],'',$datas['count']);

    }

    public function down()
    {

        $id     = $this->_params['id'];
        $this->_model = new MemberOnlineModel();
        $result = $this->_model->delById($id);
        $result? $this->ajaxSuccess():$this->ajaxError(0,"操作失败");

    }

    public function add()
    {
        // TODO: Implement add() method.
    }

    public function add_ajax()
    {
        // TODO: Implement add_ajax() method.
    }

    public function edit()
    {
        // TODO: Implement edit() method.
    }

    public function edit_ajax()
    {
        // TODO: Implement edit_ajax() method.
    }

    public function status()
    {
        // TODO: Implement status() method.
    }

    public function del()
    {
        // TODO: Implement del() method.
    }

    public function sort()
    {
        // TODO: Implement sort() method.
    }


    function reload(){
        Render::getInstance()->restartWorker();
        $this->response()->write(1);
    }

    protected function gc()
    {
        parent::gc(); // TODO: Change the autogenerated stub
        $this->_model = null;
        $this->_model_role_node = null;
    }


}
